//
//  AutoadaptationFrame.m
//  miaopai
//
//  Created by duyifang on 15/11/13.
//  Copyright © 2015年 Crow Zhang. All rights reserved.
//

#import "AutoadaptationFrame.h"

@implementation AutoadaptationFrame

//自适应宽度
+ (CGFloat)widthOfLabel:(NSString *)text andTextFont:(UIFont *)font andLableHeight:(CGFloat)height
{
    CGSize size = CGSizeMake(MAXFLOAT, height);
    NSDictionary *attributeDic = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
    CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:attributeDic context:nil];
    return frame.size.width;
}

//自适应高度
+ (CGFloat)heightOfLabel:(NSString *)text andTextFont:(UIFont *)font andLabelWidth:(CGFloat)width
{
    CGSize size = CGSizeMake(width, MAXFLOAT);
    NSDictionary *attributedDic = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
    CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:attributedDic context:nil];
    return frame.size.height;
}

@end
